<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<meta name="viewport" content="width=1000,initial-scale=1.0,maximum-scale=1.0">
		<link href="Public/Admin/css/style.css" type="text/css" rel="stylesheet"  />
		<link href="Public/Admin/css/skin/fonts/font-awesome.min.css" type="text/css" rel="stylesheet"/>
		<script type="text/javascript" src="Public/Admin/js/jquery-1.8.2.min.js"></script>
		<script type="text/javascript" src="Public/Admin/js/effect.js"></script>
		<script type="text/javascript" src="Public/Admin/js/common.js"></script>
	    <!--载入百度编辑器-->
	    <script type="text/javascript" charset="utf-8" src="Public/ueditor1_4_3/ueditor.config.js"></script>
    	<script type="text/javascript" charset="utf-8" src="Public/ueditor1_4_3/ueditor.all.min.js"> </script>
    	<script type="text/javascript" charset="utf-8" src="Public/ueditor1_4_3/lang/zh-cn/zh-cn.js"></script>
    	<!--uploadify-->
    	<script type="text/javascript" src="Public/uploadify/jquery.uploadify.min.js"></script>
    	<link rel="stylesheet" type="text/css" href="Public/uploadify/uploadify.css">
    	<!--异步-->
		<script type="text/javascript" charset="utf-8">
	    	$(function(){
	    		$("[name=category_cid]").change(function(){
	    			//抓取元素
					var type_tid = $('option:selected').attr('type_tid');
					$('#typeTid').val(type_tid);
					//给隐藏域赋值
					//$('[name=form_fid]').val(fid);
					//发送异步
					$.ajax({
						type:"post",
						url:"<?php echo U('Goods/ajaxTypeAttr')?>",
						data:{id:type_tid},
						dataType:'json',
						success:function(phpData){//请求之后，响应成功执行
							//属性（不可选）
							var Attr = '';
							//规格（可选）
							var Spec = '';
							//document.write(phpData);
							$.each(phpData,function(k,v){
								if(v.class==0){//属性
									Attr += '<tr class="info">'+
											'<td class="w160" align="center">'+ v.taname +'</td>'+
											'<td>'+
											'<select name="arr['+v.taid+']"><option value="">请选择</option>';
									$.each(v.tavalue,function(kk,vv){
										Attr += '<option value="'+ vv +'">'+ vv +'</option>';	
									});
									Attr += '</select></td></tr>';
									//document.write(Attr);
								}
								else{//规格
									Spec += '<tr class="info">'+
											'<td class="w160" align="center">'+ v.taname +'</td>'+
											'<td>'+
											'<select name="spec['+v.taid+'][value][]"><option value="">请选择</option>';
									$.each(v.tavalue,function(kk,vv){
										Spec += '<option value="'+ vv +'">'+ vv +'</option>';	
									});
									Spec += '</select></td>';
									Spec += '<td>附加价格：<input type="text" name="spec['+v.taid+'][add_price][]" /></td>';
									Spec += '<td><span class="btn-gray add-spec">增加规格</span></td>';
									Spec += '</tr>';
									//document.write(Spec);
								}
							});
						    //插入属性
		    				$('#attr').html(Attr);
		    				$('#spec').html(Spec);
						}
					});				     
	    		})	    		
	    		//添加规格
	   			$(".add-spec").live('click',function(){
					var parentTr = $(this).parents('.info');
					//克隆
					var cloneTr = parentTr.clone();
					cloneTr.find('.add-spec').removeClass('add-spec').addClass('remove-spec').html('删除规格');
					//插入到下一行
					parentTr.after(cloneTr);
					
	    		})
	    		//删除规格
	    		$(".remove-spec").live('click',function(){
	    			$(this).parents('tr').remove();
	    		})	
	    	})
	    </script>
		<!--异步_ok-->
    	<style type="text/css">
    		.divline{width:90%;height:30px;border-bottom:2px solid #F90;margin:0 auto 10px;text-align:center;line-height:30px;font-weight:bold;}	
    	</style>
	</head>
	<body class="mainbody">
<!--前端需要验证，后台也需要验证，防止前端验证失效的情况，两套验证更加保险-->
<!--导航栏-->
<div class="location">
    <a href="<?php echo U('Goods/index')?>" class="back"><i></i><span>返回列表页</span></a>
    <a href="<?php echo U('Index/index')?>" class="home" target="_blank"><i></i><span>首页</span></a>
    <i class="arrow"></i>
    <a href="<?php echo U('Goods/add')?>"><span>商品管理</span></a>
    <i class="arrow"></i>
    <span>添加商品</span>
</div>
<div class="line10"></div>
<!--/导航栏-->
		
<!--内容-->
<div id="floatHead" class="content-tab-wrap">
    <div class="content-tab">
    	<div class="content-tab-ul-wrap">
      		<div class="tab-title"><span>添加商品</span><i></i></div>
      		<ul>
        	<li><a class="selected" href="javascript:;">添加商品</a></li>   
      		</ul>
    	</div>
    </div>
</div>
<!--上传缩略图 需要enctype="multipart/form-data"和name-->
<form action="" method="post" enctype="multipart/form-data">
<div class="tab-content" style="display: block;">
	<input type="hidden" name="adminuser_aid" value="1"  />	
	<input type="hidden" name="type_tid" value=""  id="typeTid"/>
    <dl id="max">		
	    <dt>所属分类</dt>
	    <dd>
	 		<select name="category_cid"  style="border:1px solid #eee;" >
				<option value="">请选择</option>
					<?php foreach ($cateData as $v){?>
						
						<option value="<?php echo $v['cid']?>" type_tid="<?php echo $v['type_tid']?>"><?php echo $v['_name']?></option>				
							
					<?php }?>
			</select>
	    </dd>
    </dl>
    <dl>
	    <dt>所属品牌</dt>
	    <dd>
	 		<select name="brand_bid"  style="border:1px solid #eee;" >
				<option value="">请选择</option>
					<?php foreach ($brandData as $v){?>
						<option value="<?php echo $v['bid']?>"><?php echo $v['bname']?></option>
					<?php }?>
			</select>
	    </dd>
    </dl>  		
	<dl>
	    <dt>商品名称</dt>
	    <dd>
	    	<input class="input normal" type="text" placeholder="" required="" name="gname">
	      <span class="Validform_checktip">*商品名称 最多200个字符</span>
	    </dd>
    </dl>
    <dl>
	    <dt>单位</dt>
	    <dd>
	    	<input class="input normal" type="text" placeholder="" required="" name="unit" value="件">
	      <span class="Validform_checktip">*商品单位 最多150个字符</span>
	    </dd>
    </dl>
    <dl>
	    <dt>市场价</dt>
	    <dd>
	    	<input class="input normal" type="text" placeholder="" required="" name="marketprice">
	      <span class="Validform_checktip">*市场价</span>
	    </dd>
    </dl>
    <dl>
	    <dt>商城价</dt>
	    <dd>
	    	<input class="input normal" type="text" placeholder="" required="" name="shopprice">
	      <span class="Validform_checktip">*商城价</span>
	    </dd>
    </dl>
    <dl>
	    <dt>总库存</dt>
	    <dd>
	    	<input class="input normal" type="text" placeholder="" required="" name="stock">
	      <span class="Validform_checktip">*总库存</span>
	    </dd>
    </dl>
    <dl id="mark">
	    <dt>点击次数</dt>
	    <dd>
	    	<input class="input normal" type="text" placeholder="" required="" name="click">
	      <span class="Validform_checktip">*点击次数</span>
	    </dd>
    </dl>	
       
    <dl>
    	<dt>列表图</dt>
	    <dd>
	       <!-- 上传  -->
			<div lab="uploadFile">
			    <input id="f1" type="file" multiple="true" name="list_pic">
			    <span>类型: *.jpg,*.png 大小: 2000KB 数量: 1</span>
			     <!-- 上传代码 -->
			    <script type="text/javascript">
			        $(function() {//alert(1);
			            $('#f1').uploadify({
			                'formData'     : {//POST数据
			                    '<?php echo session_name();?>' : '<?php echo session_id();?>',
			                },
			                'fileTypeDesc' : '上传文件',//上传描述
			                'fileTypeExts' : '*.jpg;*.png',
			                'swf'      : '<?php echo __PUBLIC__?>/uploadify/uploadify.swf',
			                'uploader' : '<?php echo U('upload_list')?>',
			                'buttonText':'选择文件',
			                'fileSizeLimit' : '2000KB',
			                'uploadLimit' : 1,//上传文件数
			                'width':65,
			                'height':25,
			                'successTimeout':10,//等待服务器响应时间
			                'removeTimeout' : 0.2,//成功显示时间
			                'onUploadSuccess' : function(file, data, response) {
								//转为json
			                    data=$.parseJSON(data);
			                    //获得图片地址
			                    var imageUrl = data.url;
			                    var li="<li path='"+data.path+"' url='"+data.url+"'><img width='100' height='50' src='"+imageUrl+"'/><input type='hidden' name='list_pic' value='"+data.path+"'/></li>";
			                    $("#uploadList1 ul").prepend(li);
			                }
			            });
			        });
			    </script>
			    <!-- 上传代码_ok-->
			    <div id="uploadList1">
		        <ul>
		
		        </ul>
		    	</div>
			</div>
		<!--上传_ok-->
	    </dd>
  	</dl>
  	
  	<dl>
    	<dt>商品属性</dt>
	    <dd  style="width:600px;">	
	        <table width="100%" border="0" cellspacing="0" cellpadding="0" class="ltable" id="attr">
	        </table>		  
	    </dd>
    </dl>
       
    <dl>
    	<dt>商品规格</dt>
	    <dd  style="width:600px;">
	        <table width="100%" border="0" cellspacing="0" cellpadding="0" class="ltable" id="spec">
	        </table>
	    </dd>
    </dl>
    
  	
  	<dl>
    	<dt>详细页图册</dt>
	    <dd>
	      <div lab="uploadFile">
			    <input id="f2" type="file" multiple="true" name="detail_pic">
			    <span>类型: *.jpg,*.png 大小: 2000KB 数量: 10</span>
			    <script type="text/javascript">
			        $(function() {
			            $('#f2').uploadify({
			                'formData'     : {//POST数据
			                    '<?php echo session_name();?>' : '<?php echo session_id();?>',
			                },
			                'fileTypeDesc' : '上传文件',//上传描述
			                'fileTypeExts' : '*.jpg;*.png',
			                'swf'      : '<?php echo __PUBLIC__?>/uploadify/uploadify.swf',
			                'uploader' : '<?php echo U('upload_most')?>',
			                'buttonText':'选择文件',
			                'fileSizeLimit' : '2000KB',
			                'uploadLimit' : 20,//上传文件数
			                'width':65,
			                'height':25,
			                'successTimeout':10,//等待服务器响应时间
			                'removeTimeout' : 0.2,//成功显示时间
			                'onUploadSuccess' : function(file, data, response) {
								//转为json
			                    data=$.parseJSON(data);
			                    //获得图片地址
			                    var imageUrl = data.url;
			                    var li="<li path='"+data.path+"' url='"+data.url+"'><img width='100' height='50' src='"+imageUrl+"'/><input type='hidden' name='detail_pic[]' value='"+data.path+"'/></li>";
			                    $("#uploadList2 ul").prepend(li);
			                }
			            });
			        });
			    </script>
			    <style type="text/css">
			    	#uploadList2 ul li{width:100px;height:50px;display:inline-block;float:left;margin-right:5px;}
			    </style>
			    <div id="uploadList2">
			        <ul>
			
			        </ul>
		    	</div>
			</div>					           
	    </dd>
  	</dl>
  	
	<dl>
	    <dt>商品详细</dt>
	    <dd>
	        <!--调用百度编辑器 商品详细表 name="detail_desc"-->  
			<script id="detail_desc" name="detail_desc" type="text/plain" style="width:100%;height:260px;"></script>
			<script>
			var ue = UE.getEditor('detail_desc');
			</script>
	    </dd>
    </dl>
    
    <dl>
	    <dt>售后服务</dt>
	    <dd>
	        <!--调用百度编辑器    商品详细表 name="detail_service"-->
			<script id="detail_service" name="detail_service" type="text/plain" style="width:100%;height:260px;"></script>
			<script>
			var ue = UE.getEditor('detail_service');
			</script>
	    </dd>
    </dl>	
</div>
<!--/内容-->
		
<!--工具栏-->
<div class="page-footer">
  <div class="btn-wrap" style="position: static;">
    <input type="submit" name="btnSubmit" value="提交保存" id="btnSubmit" class="btn">
    <input name="btnReturn" type="button" value="返回上一页" class="btn yellow" onclick="javascript:history.back(-1);">
  </div>
</div>
<!--/工具栏-->
</form>	

	</body>
</html>